package com.jiuzhou.guanwang.jzcp.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.jiuzhou.guanwang.jzcp.R;
import com.jiuzhou.guanwang.jzcp.base.BaseRecyclerAdapter;
import com.jiuzhou.guanwang.jzcp.base.BaseRecyclerHolder;
import com.jiuzhou.guanwang.jzcp.bean.GroupResultBean;

import java.util.List;

/**
 * @ explain:
 * @ author：xujun on 2016/10/18 16:42
 * @ email：gdutxiaoxu@163.com
 */
public class TeamAdapter extends BaseRecyclerAdapter<GroupResultBean.ContentX.Rounds.Content.DataX.Data> {

    public TeamAdapter(Context context, List<GroupResultBean.ContentX.Rounds.Content.DataX.Data> datas) {
        super(context, R.layout.item_team, datas);
    }

    @Override
    public void convert(BaseRecyclerHolder holder, GroupResultBean.ContentX.Rounds.Content.DataX.Data item, int position) {
        holder.setText(R.id.tv_rank, position+1+"");
        holder.setText(R.id.tv_team_name, item.getTeam_name());
        holder.setText(R.id.tv_match_total, item.getMatches_total());
        holder.setText(R.id.tv_match_won, item.getMatches_won());
        holder.setText(R.id.tv_match_draw, item.getMatches_draw());
        holder.setText(R.id.tv_match_lost, item.getMatches_lost());
        holder.setText(R.id.tv_pro_against, item.getGoals_pro() + "/" + item.getGoals_against());
        holder.setText(R.id.tv_points, item.getPoints());

        ImageView logo = holder.getView(R.id.team_logo);
        if (!TextUtils.isEmpty(item.getTeam_logo())) {
            Glide.with(this.mContext).load(item.getTeam_logo()).into(logo);
        }else{
            Glide.with(this.mContext).load("https://img.dongqiudi.com/soccer/data/logo/team/team_default.png").into(logo);
        }
    }
}
